package ExternalService 
{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.HTTPStatusEvent;
	import flash.events.IOErrorEvent;
	import flash.events.SecurityErrorEvent;
	import flash.filesystem.File;
	/**
	 * ...
	 * @author Simon Claeye
	 */
	public class Test extends Sprite
	{
		
		public function Test() 
		{
			var token:String = "d6827948d8f58ab3b872f7b8c742b3271cddc276";
			var connection:ApiConnection = new ApiConnection();
			connection.setToken(token);
			//connection.getExcursions(loaderCompleteHandler, statusHandler, securityHandler, IOErrorHandler);
			connection.getOutcrop(1 , loaderCompleteHandler, statusHandler, securityHandler, IOErrorHandler);
		}
		
		private function cancelHandler(event:Event):void
		{
			trace("canceled");
		}
		
		private function loaderCompleteHandler(event:Object):void
		{
			var rawJSON:String = String(event.target.data);
			trace(event.target.data);
			var array:Array = JSON.parse(rawJSON) as Array
			trace(array[1]["excursion"]);
		}
		
		private function statusHandler(event:HTTPStatusEvent):void
		{
			trace("Status: "+event.status);
		}
		
		private function securityHandler(event:SecurityErrorEvent):void
		{
			trace(event);
		}
		
		private function IOErrorHandler(event:IOErrorEvent):void
		{
			var rawJSON:String = String(event.target.data);
			trace(event.target.data);
			var array:Object = JSON.parse(rawJSON)
			trace(array["excursion"]);
		}
	}

}